<?php

use think\migration\Migrator;
use think\migration\db\Column;

class OrderId extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('order');
        $table
            ->changeColumn('ware_id', 'string', array('limit' => 255, "comment" => "产品ID", "null" => true))
            ->changeColumn('product_id', 'string', array('limit' => 255, "comment" => "产品计划ID", "null" => true))
            ->changeColumn('clause_id', 'string', array('limit' => 255, "comment" => "条款ID", "null" => true))
            ->addColumn('orderId', 'string', array('limit'  => 255, 'default' => 0, 'comment' => '订单号', "null" => true, 'after' => 'order_no'))
            ->addColumn('mechanId', 'string', array('limit'  => 255, 'default' => 0, 'comment' => '渠道id', "null" => true, 'after' => 'order_no'))
            ->addColumn('insuredersJson', 'text', array('comment' => '被保人信息', "null" => true, 'after' => 'order_no'))
            ->addColumn('benefitInfo', 'text', array('comment' => '受益人信息', "null" => true, 'after' => 'order_no'))
            ->addColumn('premium', 'float', array('limit'  => '10,2', 'default' => 0, 'comment' => '保费', "null" => true, 'after' => 'commission'))
            ->addColumn('totalPremium', 'float', array('limit'  => '10,2', 'default' => 0, 'comment' => '总保费', "null" => true, 'after' => 'commission'))
            ->addColumn('totalInsured', 'float', array('limit'  => '10,2', 'default' => 0, 'comment' => '总保额', "null" => true, 'after' => 'commission'))
            ->addColumn('expireTime', 'string', array('limit'  => 50, 'default' => 0, 'comment' => '支付过期时间', "null" => true, 'after' => 'commission'))
            ->addColumn('payPerm', 'string', array('limit'  => 50, 'default' => 0, 'comment' => '缴费年限', "null" => true, 'after' => 'commission'))
            ->addColumn('payment', 'string', array('limit'  => 50, 'default' => 0, 'comment' => '缴费期限：1年，2月，4趸交，5终身，6岁', "null" => true, 'after' => 'commission'))
            ->addColumn('orderStatus', 'string', array('limit'  => 50, 'default' => 0, 'comment' => '订单状态', "null" => true, 'after' => 'order_no'))
            ->save();
    }
}
